import { Message } from '@alifd/next';
import logService from '@/services/log';

export default {
  state: {
    list: [],
  },
  reducers: {
    update: (prevState, payload) => {
      return { ...prevState, ...payload };
    },
  },
  effects: (dispatch) => ({
    getList: async (params) => {
      const data = await logService.list(params);
      if (data.code === 0) {
        dispatch.log.update({ list: data.page });
      } else {
        Message.error(data.msg);
      }
    },
  }),
};